package com.renchunlin.logindemo01.utils

import android.content.Context
import android.util.Log
import com.bumptech.glide.Glide
import com.bumptech.glide.Registry
import com.bumptech.glide.annotation.GlideModule
import com.bumptech.glide.integration.okhttp3.OkHttpUrlLoader
import com.bumptech.glide.load.model.GlideUrl
import com.bumptech.glide.module.AppGlideModule
import com.renchunlin.logindemo01.api.RetrofitClient
import java.io.InputStream

/*
 * class title: 
 * Author by RenChunLin, Email 18957806320@163.com, Date on 2021/6/23.
 * PS: Not easy to write code, please indicate.
 */

@GlideModule
class HttpGlideModule : AppGlideModule() {
    override fun registerComponents(context: Context, glide: Glide, registry: Registry) {
        Log.d("HttpGlideModule", "registerComponents: ")
        registry.replace(
            GlideUrl::class.java,
            InputStream::class.java,
            OkHttpUrlLoader.Factory(RetrofitClient.okHttpClient)
        )
    }
}
